package com.clothing.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import com.clothing.entity.Business;
import com.clothing.entity.User.Status;
import com.clothing.service.BusinessService;
import com.clothing.utils.Utils;
import com.clothing.utils.page.Filter;
import com.clothing.utils.page.Page;
import com.clothing.utils.page.Pageable;


/**
 * @ClassName: BusinessServiceImpl 
 * @Description: TODO(Business-ServiceImpl)
 * @author Charles
 * @date 2018年5月27日
 * @version 1.0
 */
@Service
public class BusinessServiceImpl extends
        BaseServiceImpl<Business, Long> implements BusinessService
{

    @Override
    public Page<Business> findPage(String keyword, Status status,
            Pageable pageable)
    {
        List<Filter> filters = new ArrayList<>();
        
        if (!Utils.isEmpty(keyword))
        {
            filters.add(Filter.like("name", "%" + keyword + "%"));
        }
        
        if (null != status)
        {
            filters.add(Filter.eq("user.status", status));
        }
        
        pageable.setFilters(filters);
        
        return findPage(pageable);
    }

}
